package com.jinxin.platform.cdfaceacs.controller;

import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdfaceacs.pojo.domains.AcsControlRoomInfoDO;
import com.jinxin.platform.cdfaceacs.service.AcsControlBlockInfoService;
import com.jinxin.platform.cdfaceacs.service.AcsControlRoomInfoService;
import com.jinxin.platform.cdfaceacs.service.AcsControlUserInfoService;
import com.jinxin.platform.cdfaceacs.service.JurenAcsCommunityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2020-10-12
 * @Author: Lingnan
 **/
@RestController
@RequestMapping("/unAuth/basicInfo")
@Slf4j
public class AcsBasicInfoController {
    @Autowired
    private JurenAcsCommunityService acsCommunityService;
    @Autowired
    private AcsControlUserInfoService userInfoService;
    @Autowired
    private AcsControlBlockInfoService blockInfoService;
    @Autowired
    private AcsControlRoomInfoService roomInfoService;

    /**
     * 根据楼栋id获取房间列表
     * @return
     */
    @RequestMapping("/listRoomsById")
    public JsonResult listRoomsById(String blockId){
        if(StringUtils.isEmpty(blockId)){
            return JsonResult.error("楼栋id不能为空");
        }
        AcsControlRoomInfoDO paramDO = new AcsControlRoomInfoDO();
        paramDO.setBlockId(blockId);
        List<AcsControlRoomInfoDO> RoomInfoDOS = roomInfoService.selDOByInfo(paramDO);
        return JsonResult.ok(RoomInfoDOS);
    }

    @RequestMapping("/getBlockInfoList")
    public JsonResult getBlockInfoList(String blockId){
        if(StringUtils.isEmpty(blockId)){
            return JsonResult.ok("楼栋ID不能为空");
        }
        return JsonResult.ok(blockInfoService.getBlockInfoList(blockId));
    }

    @RequestMapping("/countUserByAgeRange")
    public JsonResult countUserByAgeRange(){
        return JsonResult.ok(userInfoService.countUserByAgeRange());
    }

    @RequestMapping("/countUserByType")
    public JsonResult countUserByType(){
        return JsonResult.ok(userInfoService.countUserByType());
    }
    @RequestMapping("/countUserByPartyType")
    public JsonResult countUserByPartyType(){
        return JsonResult.ok(userInfoService.countUserByMType());
    }

    @RequestMapping("/countOldUserByAgeRange")
    public JsonResult countOldUserByAgeRange(){
        return JsonResult.ok(userInfoService.countOldUserByAgeRange());
    }

}
